<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../config.inc.php");

$_LangPath = "specialnumber";	//語言檔參數，務必放在最前面
include_once(__Member_Path."/logincheck_nodb.php");
include_once(__Language_Path."/selectlanguage_member.php");

$objMemberInfo = $_SESSION["Member_Info"];

$fp = @file(__Membertemplate_Path."/specialnumber_".$_data["stype"].".html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);
$fp = str_replace("{SelfFile}", $_SERVER["PHP_SELF"], $fp);
$fp = str_replace("{ShowAccount}", $objMemberInfo -> Account, $fp);
$fp = str_replace("{UserID}", $objMemberInfo -> ID, $fp);
$fp = str_replace("{sid}", $_data["sid"], $fp);

$intLID = (int)$_data["LottoID"];
if(empty($intLID))$intLID = 1;

$isSpecial = (int)$_data["isSpecial"];
if(empty($isSpecial))$isSpecial = 1;

include_once(__Common_Path."/SysParam.inc.php");
include_once(__Common_Path."/limit/LottoLimit_".$intLID.".inc.php");
include_once(__Common_Path."/betparam/BetParam_".$intLID.".inc.php");
include_once(__Root_Path."/tmp/credit-".$objMemberInfo -> ID.".php");
@include_once(__Common_Path."/todaygame/Gamble".$intLID.".inc.php");
include_once(__Common_Path."/Lotto.inc.php");
include_once(__Common_Path."/ExchangeRate.inc.php");
include_once(__Modules_Path."/ChangeTime.lib.php");

if(__isConnectToOtherWeb == 1){
	$flMemERate = (empty($objMemberInfo -> ExRate))?1:$objMemberInfo -> ExRate;
}else{
	$flMemERate = (empty($_ECRate[$objMemberInfo -> ERID]["Rate"]))?1:$_ECRate[$objMemberInfo -> ERID]["Rate"];
}
$intLType = $_arrLotto[$intLID]["LType"];
//取出此期賽程
if(is_array($_arrGamble))list($intGID, $arrGamble) = each($_arrGamble);

$intTmp = $objMemberInfo -> CreditLine - $_arrMemStake["_SUM"];
$fp = str_replace("{CreditValue}", $intTmp, $fp);

$fp = str_replace("{LottoID}", $intLID, $fp);
$fp = str_replace("{ColorSet}", $_arrLotto[$intLID]["ColorSet"], $fp);
$fp = str_replace("{DrawSpecial}", $_arrLotto[$intLID]["DrawSpecial"], $fp);
$fp = str_replace("{SpecialOverNumber}", $_arrLotto[$intLID]["SpecialOverNumber"], $fp);

if (!is_array($arrGamble)) {
	$strDate = "2100-01-01 01:01:01";
} else {
	$strDate = TimeForm($arrGamble[GameDate], $arrGamble[EndGameTime], "Y-m-d H:i:s", "UToC");
}
$fp = str_replace("{EndGameTime}", $strDate, $fp);
$fp = str_replace("{isSpecial}", $isSpecial, $fp);

if($isSpecial == 4){
	$fp = str_replace("{Bet_Type}", "4,5,6", $fp);
	$fp = str_replace("{Title}", $_arrBet_Type[$intLType][4], $fp);
	$fp = str_replace("{SpecialOdd}", $_strSpecialNumber["NormalOdd"], $fp);
	$fp = str_replace("{SpecialEven}", $_strSpecialNumber["NormalEven"], $fp);
	$fp = str_replace("{SpecialOver}", $_strSpecialNumber["NormalOver"], $fp);
	$fp = str_replace("{SpecialUnder}", $_strSpecialNumber["NormalUnder"], $fp);
	$fp = str_replace("{MSite}", "2", $fp);	//走馬燈位置
	$fp = preg_replace("/<!--@ SumOddEven Start @\/\/-->.+<!--@ SumOddEven End @\/\/-->/s", "", $fp);
	$fp = preg_replace("/<!-- NormlSpecial Bar Start \/\/-->.+<!-- SpecialNumber Bar End \/\/-->/s", "", $fp);
	$intBID = 4;
	$intGap = 2;
}else{
	if($isSpecial == 1 || $isSpecial == 28){
		$fp = str_replace("{Bet_Type}", $isSpecial.",2,3,16", $fp);
		if($_KSysParam[isOpenSpecialNumberBLine] == 1){
			$fp = preg_replace("/<!-- NormlSpecial Bar Start \/\/-->.+<!-- NormlSpecial Bar End \/\/-->/s", "", $fp);
			$fp = str_replace("<td class=\"rt_sp_nsbar\" id=\"NSBar".($isSpecial==1?"1":"2")."\">", "<td class=\"rt_sp_nsbar_sd\" id=\"NSBar".(string)((int)$isSpecial==1?"1":"2")."\">", $fp);
		}else{
			$fp = preg_replace("/<!-- NormlSpecial Bar Start \/\/-->.+<!-- SpecialNumber Bar End \/\/-->/s", "", $fp);
		}
	}else{
		$fp = str_replace("{Bet_Type}", $isSpecial, $fp);
		$fp = str_replace("<td class=\"rt_sp_nsbar\" id=\"NSBar".(string)($isSpecial%10)."\">", "<td class=\"rt_sp_nsbar_sd\" id=\"NSBar".(string)((int)$isSpecial%10)."\">", $fp);
		$fp = preg_replace("/<!--No Number Start\/\/-->.+<!--No Number End\/\/-->/s", "", $fp);
		$fp = preg_replace("/<!-- SpecialNumber Bar Start \/\/-->.+<!-- SpecialNumber Bar End \/\/-->/s", "", $fp);
		for($i = 1; $i <= 6; $i++){
			$fp = str_replace("{NSBar$i}", str_replace("1", $i, $_strSpecialNumber["NormalSpecial1"]), $fp);
		}
	}
	$fp = str_replace("{Title}", $_arrBet_Type[$intLType][$isSpecial], $fp);
	$fp = str_replace("{SpecialOdd}", $_strSpecialNumber["SpecialOdd"], $fp);
	$fp = str_replace("{SpecialEven}", $_strSpecialNumber["SpecialEven"], $fp);
	$fp = str_replace("{SpecialOver}", $_strSpecialNumber["SpecialOver"], $fp);
	$fp = str_replace("{SpecialUnder}", $_strSpecialNumber["SpecialUnder"], $fp);
	$fp = str_replace("{MSite}", "2", $fp);	//走馬燈位置
	$intBID = $isSpecial;
	$intGap = 0;
}
$fp = str_replace("{WType_NB}", $_arrBet_Type[$intLType][4], $fp);
$fp = str_replace("{WType_SpA}", $_arrBet_Type[$intLType][1], $fp);
$fp = str_replace("{WType_SpB}", $_arrBet_Type[$intLType][28], $fp);
$fp = str_replace("{WType_NSB}", $_arrBet_Type[$intLType][21], $fp);
$intAN = 0;
if($_data["stype"] == "c"){
	$arrTmpBT = array(1, 2, 3, 4, 5, 6, 16, 21, 22, 23, 24, 25, 26, 28);
	while(list($k, $v) = each($arrTmpBT)){
		$fp = str_replace("{MaxEventLimitValue$v}", $objMemberInfo -> arrEventLimit[$intLID][$v], $fp);
		$fp = str_replace("{MaxBetLimitValue$v}", $objMemberInfo -> arrBetLimit[$intLID][$v], $fp);
		$fp = str_replace("{LottoMaxEventLimitValue$v}", floor($_arrLottoLimit[$v][0] / $flMemERate), $fp);
		$fp = str_replace("{LottoMaxBetLimitValue$v}", floor($_arrLottoLimit[$v][1] / $flMemERate), $fp);
		$fp = str_replace("{MinStake$v}", floor($_arrBetParam[$v][$intAN]["MinStake"] / $flMemERate), $fp);
		$fp = str_replace("{MaxPayOff$v}", floor($_arrBetParam[$v][$intAN]["MaxPayOff"] / $flMemERate), $fp);
	}
	foreach($_arrAnimals as $k => $strAn){
		if($k == 0)continue;
		$fp = str_replace("{An".$k."}", $strAn, $fp);
	}

}elseif($_data["stype"] == "q"){
	foreach($_arrAnimals as $k => $strAn){
		if($k == 0)continue;
		$fp = str_replace("{An".$k."}", $strAn, $fp);
	}
}
$fp = str_replace("{MaxEventLimitValue}", $objMemberInfo -> arrEventLimit[$intLID][$intBID], $fp);
$fp = str_replace("{MaxBetLimitValue}", $objMemberInfo -> arrBetLimit[$intLID][$intBID], $fp);
$fp = str_replace("{LottoMaxEventLimitValue}", floor($_arrLottoLimit[$intBID][0] / $flMemERate), $fp);
$fp = str_replace("{LottoMaxBetLimitValue}", floor($_arrLottoLimit[$intBID][1] / $flMemERate), $fp);
$fp = str_replace("{MinStakeValue}", floor($_arrBetParam[$intBID][$intAN]["MinStake"] / $flMemERate), $fp); //最低下注金額
$fp = str_replace("{MaxPayOff}", $_arrBetParam[$intBID][$intAN]["MaxPayOff"], $fp);	//最高派彩

$fp = str_replace("{time}", "04", $fp);

while(list($k, $v) = each($_strSpecialNumber)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

//輸出
WebOutputHTML($fp, 1);
?>